# -*- coding: utf-8 -*- 
import time
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains

# 实例化一个启动参数对象
chrome_options = Options()
# 添加启动参数
chrome_options.add_argument('--disable-infobars')
#chrome_options.add_argument('--start-maximized')
#chrome_options.add_argument('--headless')
# 将参数对象传入Chrome
brower = webdriver.Chrome(executable_path = r"D:/user/Downloads/chromedriver",chrome_options=chrome_options)

#brower = webdriver.Chrome(executable_path = r"D:/user/Downloads/chromedriver")
time.sleep(2)
brower.get('http://itsm-rpt.sf-express.com/balantflow/')

#账号
zh = brower.find_element_by_id("username")
zh.send_keys("01383317")

#密码
mm = brower.find_element_by_id("password")
mm.send_keys("liuj1a!wei")

time.sleep(8)
#登陆
brower.find_element_by_css_selector(".f18.logn_lt.logn_btn.lh46").click()


#查询
cx = brower.find_elements_by_css_selector(".menu-text")[2]
print cx
cx.click()
time.sleep(2)
#单纯点击
gdcx = brower.find_elements_by_class_name("tab-text")[1] 
#gdcx.click()

#定位到ifarme里面才能进行下一步
#brower.switch_to_frame("iframe-item-8438a028-7d7b-4056-8722-31ad65bd81a3")
#动态定位
brower.switch_to.frame(brower.find_elements_by_css_selector(".iframe-item")[1])
ss = brower.find_element_by_id("divSearch")
ss.click()
time.sleep(1)

#定位流水号
lsh = brower.find_element_by_xpath("/html/body/div[1]/div[2]/div[1]/div[2]/div[2]/input")
lsh.clear()
lsh.send_keys("RL003692515")
time.sleep(1)
qd = brower.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/button[1]").click()
time.sleep(1)

#点击标题
djbt = brower.find_element_by_xpath('.//*[@id="mainDiv"]/table/tbody/tr[1]/td[1]/div/a').click()

#点击查看
chakan = brower.find_element_by_css_selector("#menuDiv_3692515 > ul > li:nth-child(1) > a")
time.sleep(2)
chakan.click()



#退出iframe
#brower.switch_to_default_content()


